package com.homedo.odin.solution.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.homedo.core.common.base.service.BaseService;
import com.homedo.odin.solution.dao.HebiOrderMapper;
import com.homedo.odin.solution.model.dto.PageBean;
import com.homedo.odin.solution.model.entity.HebiOrder;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p> 订单流水号 服务实现类 </p>
 *
 * @author HarveyDing
 * @since 2018-03-15
 */
@Service
public class HebiOrderServiceImpl extends BaseService<HebiOrderMapper, HebiOrder> {

    public PageInfo<HebiOrder> getProfitList(PageBean pageBean, int userId, String bizId, String bizType) {
        Map<String, Object> map = new HashMap<>();
        map.put("user_id", userId);
        map.put("is_del", 0);
        if (!StringUtils.isEmpty(bizId)) {
            map.put("biz_id", bizId);
        }
        if (!StringUtils.isEmpty(bizType)) {
            map.put("biz_type", bizType);
        }
        map.put("status", "profit");
        PageHelper.startPage(pageBean.getCurrentPage(), pageBean.getPageSize());
        return new PageInfo<HebiOrder>(baseMapper.selectByMap(map));
    }

    /**
     * 获取收益总和
     */
    public HebiOrder getProfitAmount(int userId) {
        return baseMapper.getProfitAmount(userId);
    }

    public Integer queryHebiByBusinessId(String bizId) {
        return baseMapper.queryHebiByBusinessId(bizId);
    }
}
